﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

public partial class MasterPage : System.Web.UI.MasterPage
{
    MaintenanceBLL maintenanceLogic = new MaintenanceBLL();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Maintenance.MaintenanceRow maintenance = maintenanceLogic.GetMaintenance("Application");
            if (maintenance.IsEnabled)
            {
                lblApplicationMaintenanceMessage.Text = maintenance.Message;
                PanelApplicationMaintenance.Visible = true;
            }
            else
            {
                PanelApplicationMaintenance.Visible = false;
            }
        }
    }
    protected void LoginStatus2_LoggingOut(object sender, LoginCancelEventArgs e)
    {
        try
        {
            int StatsLoginID = Convert.ToInt32(Session["StatsLoginID"].ToString());

            StatisticsBLL statsLogic = new StatisticsBLL();

            Statistics.Stats_LoginRow statsLogin = statsLogic.GetStatsLoginByStatsLoginID(StatsLoginID);
            statsLogic.UpdateLogoutDateTime(DateTime.Now, StatsLoginID);
        }
        finally
        {
            Session.Clear();
            Session.Abandon();
            FormsAuthentication.SignOut();
            Response.Redirect("MyClasses.aspx");
        }
    }
}
